package com.example.article.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.article.entity.User;
import com.example.article.mapper.UserMapper;
import com.example.article.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zhaung
 * @since 2022-04-18
 */
@Service
@RequiredArgsConstructor
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {


    private final BCryptPasswordEncoder encoder;

    private final UserMapper userMapper;

    public Boolean insUser(User user) {

//        加密
        user.setPassword(encoder.encode(user.getPassword()));
//        解密
//        encoder.matches("明文","密文");

        return true;


    }

    @Override
    public User selUserById(Long id) {
        return userMapper.selUserById(id);
    }
}
